/*
 * @Description: 
 * @Author: Junhuang
 * @Date: 2022-02-08 14:47:32
 * @LastEditTime: 2022-02-15 17:16:22
 * @LastEditors: Junhuang
 * @Reference: 
 */
'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE, ENUM, TEXT } = Sequelize;
    // 创建表
    await queryInterface.createTable('user', {
      id: { type: INTEGER(20), primaryKey: true, autoIncrement: true, comment: '主键id' },
      username: { type: STRING(30), allowNull: false, defaultValue: '', comment: '用户名称', unique: true },
      nickname: { type: STRING(30), allowNull: false, defaultValue: '', comment: '昵称' },
      email: { type: STRING(160), allowNull: false, defaultValue: '', comment: '电子邮箱' },
      password: { type: STRING, allowNull: false, defaultValue: '', comment: '密码' },
      avatar: { type: STRING, allowNull: true, defaultValue: '', comment: '头像' },
      phone: { type: STRING(11), allowNull: false, defaultValue: '', comment: '手机' },
      sex: { type: ENUM, values: ['男', '女', '保密'], allowNull: false, defaultValue: '男', comment: '性别' },
      description: { type: TEXT, allowNull: false, defaultValue: '', comment: '个性签名' },
      created_time: DATE,
      updated_time: DATE
    });
  },

  down: async queryInterface => {
    await queryInterface.dropTable('user')
  }
};